﻿using Flurl.Http;
using HandyControl.Controls;
using HandyControl.Tools.Extension;
using ImTools;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection.Emit;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Shell;
using wms_wpf.Dto;
using wms_wpf.InPut;

namespace wms_wpf.Apiservice
{
    public class BaseService : IBaseService
    {

        string config = Environment.GetEnvironmentVariable("上海铁路通信-config", EnvironmentVariableTarget.Machine);
        string Machine = Environment.GetEnvironmentVariable("Machine", EnvironmentVariableTarget.Machine);
        public async Task<string> Create_Boxs(InPut_BaseService input)
        {

            try
            {
                var url = $"http://{config}/api/BaseService/Create_Boxs";
                var data = input;
                string result = await url.WithHeader("Authorization", " Bearer" + " " + Jwt.JwtKey).PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.Msg;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.Msg;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("Create_Boxs", ex);
                return null;
            }
        }//配置箱盒
        public async Task<string> Create_Warehouses(InPut_BaseService3 input)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/Create_Warehouses";
                var data = input;
                string result = await url.WithHeader("Authorization", " Bearer" + " " + Jwt.JwtKey).PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.Msg;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.Msg;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("Create_Warehouses", ex);
                return null;
            }
        }//配置库位
        public async Task<Tuple<List<BoxDto>, long?, long?>> GetList_Boxs(InPut_BaseService6 inPut)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/GetList_Boxs";
                var data = inPut;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponsePage Response = JsonConvert.DeserializeObject<ApiResponsePage>(result);
                if (Response.State)
                {
                    List<BoxDto> res = JsonConvert.DeserializeObject<List<BoxDto>>(Response.Dto.ToString());
                    return Tuple.Create(res, Response.Count, Response.PageCount);
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;
                }


            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog(" GetList_Boxs", ex);
                return null;
            }
        }//获取箱盒表
        public async Task<Tuple<List<WarehouseLineDto>, long?, long?>> GetList_WarehouseLine(InPut_BaseService4 input)//获取库位表
        {
            try
            {
                var url = $"http://{config}/api/BaseService/GetList_WarehouseLine";
                var data = input;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponsePage Response = JsonConvert.DeserializeObject<ApiResponsePage>(result);
                if (Response.State)
                {
                    List<WarehouseLineDto> res = JsonConvert.DeserializeObject<List<WarehouseLineDto>>(Response.Dto.ToString());
                    return Tuple.Create(res, Response.Count, Response.PageCount);
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;
                }


            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("GetList_WarehouseLine", ex);
                return null;
            }
        }
        public async Task<bool> Update_WarehouseLines(InPut_BaseService5 inPut)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/Update_WarehouseLines";
                var data = inPut;
                string result = await url.WithHeader("Authorization", " Bearer" + " " + Jwt.JwtKey).PostJsonAsync(data).ReceiveString();
                ApiResponsePage Response = JsonConvert.DeserializeObject<ApiResponsePage>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                }
                return true;

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("Update_WarehouseLines", ex);
                return false;
            }
        }//更新库位状态
        public async Task<bool> Update_Box(InPut_BaseService2 input)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/Update_Box";
                var data = input;
                string result = await url.WithHeader("Authorization", " Bearer" + " " + Jwt.JwtKey).PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.State;
                }
                else
                {
                    if (!Response.Msg.Contains("先别急"))
                    {
                        Growl.Info(Response.Msg, "msg");
                    }

                    return Response.State;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("Update_Box", ex);
                return false;
            }
        }
        public async Task<string> CreateNeetOutMaterial(InPut_BaseService10 InPut)//手动出库-添加需出料
        {
            try
            {
                var url = $"http://{config}/api/BaseService/CreateNeetOutMaterial";
                var data = InPut;
                string result = await url.WithHeader("Authorization", " Bearer" + " " + Jwt.JwtKey).PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.Msg;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.Msg;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("CreateNeetOutMaterial", ex);
                return null;
            }
        }
        public async Task<BaseDto> DeleteMaterial(InPut_BaseService8 InPut)//取料确认
        {
            try
            {
                var url = $"http://{config}/api/BaseService/DeleteMaterial";
                var data = InPut;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    BaseDto dto = JsonConvert.DeserializeObject<BaseDto>(Response.Dto.ToString());
                    Growl.Success(Response.Msg, "msg");
                    return dto;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("DeleteMaterial", ex);
                return null;
            }
        }
        public async Task<BaseDto> GetDeleteMaterial(InPut_BaseService8 InPut)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/GetDeleteMaterial";
                var data = InPut;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    BaseDto dto = JsonConvert.DeserializeObject<BaseDto>(Response.Dto.ToString());
                    return dto;

                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;

                }
            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("GetDeleteMaterial", ex);
                return null;
            }
        }
        public async Task<string> Create_Inlethouse(InPut_BaseService9 input)//添加入库口
        {
            try
            {
                var url = $"http://{config}/api/BaseService/Create_Inlethouse";
                var data = input;
                string result = await url.WithHeader("Authorization", " Bearer" + " " + Jwt.JwtKey).PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.Msg;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.Msg;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("Create_Inlethouses", ex);
                return null;
            }
        }
        public async Task<List<string>> GetList_InlethouesCode(string Type)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/GetList_InlethouesCode?Type={Type}";
                string result = await url.PostAsync().ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {

                    List<string> dto = JsonConvert.DeserializeObject<List<string>>(Response.Dto.ToString());
                    return dto;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("DeleteMaterial", ex);
                return null;
            }
        }//获取出口
        public async Task<string> UpdateTaskOrderState(InPut_BaseService11 InPut)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/UpdateTaskOrderState";
                var data = InPut;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    //Growl.Success(Response.Msg, "msg");
                    return Response.Msg;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.Msg;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("UpdateTaskOrderState", ex);
                return null;
            }
        }//更新任务状态
        public async Task<string> CreateTaskOrder(InPut_BaseService12 InPut)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/CreateTaskOrder";
                var data = InPut;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    Growl.Success(Response.Msg, "msg_2");
                    return Response.Dto.ToString();
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    Growl.Info(Response.Msg, "msg_2");
                    return null;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                Growl.Error("接口调用失败", "msg_2");
                LognetHelper.WriteLog("CreateTaskOrder", ex);
                return null;
            }
        }//手动入库
        public async Task<string> CreateTaskOrderOut(InPut_BaseService13 InPut)
        {
            try
            {
                if (Machine== "3")
                {
                    InPut.InlethouseCode = "3";
                }
                var url = $"http://{config}/api/BaseService/CreateTaskOrderOut";
                var data = InPut;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.Msg;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.Msg;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("CreateTaskOrderOut", ex);
                return null;
            }
        }//手动出库
        public async Task<string> DeleteTaskOrder(List<string> TaskOrderCodes)//删除任务
        {
            try
            {
                var url = $"http://{config}/api/BaseService/DeleteTaskOrder";
                var data = TaskOrderCodes;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.Msg;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.Msg;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("DeleteTaskOrder", ex);
                return null;
            }
        }
        public async Task<string> MergeBox(InPut_BaseService14 InPut)//合箱
        {
            try
            {
                var url = $"http://{config}/api/BaseService/MergeBox";
                var data = InPut;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                  await CreateLog("修改", "合箱成功了:" + InPut.MaterialCode + "从" + InPut.BoxCode + "到" + InPut.NBoxCodeGrid);
                    return Response.Msg;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("MergeBox", ex);
                return null;
            }
        }
        public async Task<bool> CreateMaterialBase(InPut_BaseService7 inPut)//新料入库
        {
            try
            {
                var url = $"http://{config}/api/BaseService/CreateMaterialBase";
                var data = inPut;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    Growl.Success(Response.Msg, "msg_2");
                    return Response.State;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    Growl.Info(Response.Msg, "msg_2");
                    return Response.State;
                }
            }
            catch (Exception ex)
            {
                Growl.Error(inPut.MaterialCode + "入料时发生错误", "msg");
                Growl.Error(inPut.MaterialCode + "入料时发生错误", "msg_2");
                LognetHelper.WriteLog("CreateMaterialBase" + inPut.MaterialCode, ex);
                return false;
            }
        }
        public async Task<string> CreateLog(string Type, string Note)//生成日志
        {
            try
            {
                InPut_BaseService15 InPut = new InPut_BaseService15();
                InPut.Type = Type;
                InPut.Note = Note;
                InPut.User = Jwt.UserName;
                var url = $"http://{config}/api/BaseService/CreateLog";
                var data = InPut;
                string result = await url.PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {

                    return Response.Msg;
                }
                else
                {
                    return Response.Msg;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("CreateLog", ex);
                return null;
            }
        }
        public async Task<string> UpdateNeetQuantity(InPut_BaseService16 InPut)//编辑需求出库数量
        {
            try
            {
                var url = $"http://{config}/api/BaseService/UpdateNeetQuantity";
                var data = InPut;
                string result = await url.WithHeader("Authorization", " Bearer" + " " + Jwt.JwtKey).PostJsonAsync(data).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.Msg;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.Msg;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("UpdateNeetQuantity", ex);
                return null;
            }
        }
        public async Task<List<View_NeetOutMaterialDto>> GetNeetBoxMaterial(string BoxCode)//获取需要出库物料
        {
            try
            {
                var url = $"http://{config}/api/BaseService/GetNeetBoxMaterial?BoxCode={BoxCode}";
                string result = await url.PostAsync().ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {

                    List<View_NeetOutMaterialDto> dto = JsonConvert.DeserializeObject<List<View_NeetOutMaterialDto>>(Response.Dto.ToString());
                    return dto;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("GetNeetBoxMaterial接口调用失败", "msg");
                LognetHelper.WriteLog("GetNeetBoxMaterial", ex);
                return null;
            }
        }
        public async Task<BaseDto2> GetWarehousequantity()//使用数量
        {
            try
            {
                var url = $"http://{config}/api/BaseService/GetWarehousequantity";
                string result = await url.PostAsync().ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    BaseDto2 dto = JsonConvert.DeserializeObject<BaseDto2>(Response.Dto.ToString());
                    return dto;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("GetWarehousequantity", ex);
                return null;
            }
        }
        public async Task<bool> Revoke_MaterialBase(string LPN)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/Revoke_MaterialBase?LPN={LPN}";
                string result = await url.PostAsync().ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.State;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return false;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("Revoke_MaterialBase", ex);
                return false;
            }
        }
        public async Task<List<CusetomOrderDto>> GetListCusetom(InPut_BaseService17 InPut)//获取用户工单
        {
            try
            {
                var url = $"http://{config}/api/BaseService/GetListCusetom";
                if (InPut.State == null)
                {
                    InPut.State = "未分配";
                }
                string result = await url.PostJsonAsync(InPut).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    List<CusetomOrderDto> res = JsonConvert.DeserializeObject<List<CusetomOrderDto>>(Response.Dto.ToString());
                    return res;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("获取用户工单接口调用失败", "msg");
                LognetHelper.WriteLog("GetListCusetom");
                return null;
            }
        }
        public async Task<List<CusetomLineDto>> GetListCusetomLine(Guid CusetomOrder_Id)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/GetListCusetomLine?CusetomOrder_Id={CusetomOrder_Id}";
                string result = await url.PostAsync().ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    List<CusetomLineDto> res = JsonConvert.DeserializeObject<List<CusetomLineDto>>(Response.Dto.ToString());
                    return res;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("获取用户工单详情接口调用失败", "msg");
                LognetHelper.WriteLog("GetListCusetomLine");
                return null;
            }
        }
        public async Task<bool> CreateTaskNeetOut(InPut_BaseService20 InPut)
        {
            try
            {


                var url = $"http://{config}/api/BaseService/CreateTaskNeetOut";
                string result = await url.PostJsonAsync(InPut).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    return Response.State;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.State;
                }
            }
            catch (Exception ex)
            {

                Growl.Error("分配工单详情接口调用失败", "msg");
                LognetHelper.WriteLog("CreateTaskNeetOut:" + ex.ToString());
                return false;
            }
        }
        public async Task<bool> DeleteNeetMaterial(string MaterialCode)//删除需出料
        {
            try
            {
                var url = $"http://{config}/api/BaseService/DeleteNeetMaterial?MaterialCode={MaterialCode}";
                string result = await url.PostAsync().ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.State;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return false;
                }

            }
            catch (Exception ex)
            {
                Growl.Error("接口调用失败", "msg");
                LognetHelper.WriteLog("Revoke_MaterialBase", ex);
                return false;
            }
        }
        public async Task<bool> CreateTaskManyNeetOut(InPut_BaseService20 InPut)//合并工单
        {
            try
            {
                var url = $"http://{config}/api/BaseService/CreateTaskManyNeetOut";
                string result = await url.PostJsonAsync(InPut).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {

                    return Response.State;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.State;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("合并工单详情接口调用失败", "msg");
                LognetHelper.WriteLog("CreateTaskManyNeetOut");
                return false;
            }
        }
        public async Task<bool> CheckNeetTask()//验证未出料
        {
            try
            {
                var url = $"http://{config}/api/BaseService/CheckNeetTask";
                string result = await url.PostAsync().ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    return Response.State;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.State;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("验证未出料接口失败", "msg");
                LognetHelper.WriteLog("CheckNeetTask");
                return false;
            }
        }
        public async Task<bool> DeleteWaste()//删除废料
        {
            try
            {
                var url = $"http://{config}/api/BaseService/DeleteWaste";
                string result = await url.PostAsync().ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.State;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.State;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("验证未出料接口失败", "msg");
                LognetHelper.WriteLog("DeleteWaste");
                return false;
            }
        }
        public async Task<bool> UpdateMaterialQuantity(InPut_BaseService19 InPut)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/UpdateMaterialQuantity";
                string result = await url.WithHeader("Authorization", " Bearer" + " " + Jwt.JwtKey).PostJsonAsync(InPut).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.State;

                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.State;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("修改库存接口失败", "msg");
                LognetHelper.WriteLog("UpdateMaterialQuantity");
                return false;
            }
        }
        public async Task<List<NeetOutMaterialsDto>> CreateTaskManyNeetOutNew(InPut_BaseService21 InPut)//合并工单新
        {
            try
            {
                var url = $"http://{config}/api/BaseService/CreateTaskManyNeetOutNew";
                string result = await url.PostJsonAsync(InPut).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    List<NeetOutMaterialsDto> res = JsonConvert.DeserializeObject<List<NeetOutMaterialsDto>>(Response.Dto.ToString());
                    return res;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return null;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("合并工单详情接口调用失败", "msg");
                LognetHelper.WriteLog("CreateTaskManyNeetOutNew");
                return null;
            }
        }
        public async Task<bool> GetListOrder()
        {
            try
            {
                var url = $"http://{config}/api/BaseService/GetListOrder";
                string result = await url.PostAsync().ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.State;

                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.State;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("修改库存接口失败", "msg");
                LognetHelper.WriteLog("UpdateMaterialQuantity");
                return false;
            }
        }
        public async Task<bool> DeleteOrder(List<Guid> InPut)
        {
            try
            {
                var url = $"http://{config}/api/BaseService/DeleteOrder";
                string result = await url.PostJsonAsync(InPut).ReceiveString();
                ApiResponse Response = JsonConvert.DeserializeObject<ApiResponse>(result);
                if (Response.State)
                {
                    Growl.Success(Response.Msg, "msg");
                    return Response.State;
                }
                else
                {
                    Growl.Info(Response.Msg, "msg");
                    return Response.State;
                }
            }
            catch (Exception ex)
            {
                Growl.Error("删除工单", "msg");
                LognetHelper.WriteLog("DeleteOrder:" + ex.ToString());
                return false;
            }
        }
    }
}
